#include <qapplication.h>
#include <qpushbutton.h>
#include <qfont.h>
#include <qpainter.h>
#include <qbitmap.h>
#include <qstring.h>
#include <qtimer.h>
#include <qgl.h>

#include "CDGWidgetBase.h"
#include "background.h"
#include "osd.h"
#include "cdgclock.h"


class CDGWidgetGL : public QGLWidget, public CDGWidgetBase
{
  Q_OBJECT;
  public:
    CDGWidgetGL(QWidget *parent=0, const char *name=0 );
    virtual ~CDGWidgetGL();

    bool play(const QString& filename,
              bool useTransp=true, bool useTransBkg=true, bool useTransBorder=true);
    void stop();
    void info();
    static int GetNearestGLTextureSize(int v);

 public slots:
    void nextPos();

  protected:
    void initializeGL(void);
    void resizeGL(int w, int h);
    void paintGL(void);
    void paintCDGFrame(void);
    void paintCDG(void);
    void customEvent(QCustomEvent *event);

    void CreateCDG();

 private:
    GLuint m_cdgTexture;
    float  m_cdgTextHeight;
    float  m_cdgTextWidth;

    // Frame
    bool   m_showFrame;
    GLuint m_frameTexture;

    // Info
    osd   m_info;

    // Background
    background m_bkg;

    // Background
    cdgclock m_clock;
};

